{% extends "base.html" %}

{% block title %}Flasky - User{% endblock %}

{% block page_content %}
<div class="page-content">
    <img class="img-rounded" src="{{user.gravatar(size=256)}}">
    <h1>{{user.username}}</h1>
    {% if current_user.is_administrator() %}
    <p><a href="#">{{user.email}}</a></p>
    {% endif %}
    {% if user.about_me %}
    <p>{{user.about_me|safe}}</p>
    {% endif %}

    {% if user.imagesrc %}
    <p><img src="{{user.imagesrc}}" class="img-thumbnail"></p>
    {% endif %}


    <p>Member since: {{moment(user.member_since).format('L')}}.</p>
    <p>Last seen: {{moment(user.last_seen).format('L')}}.</p>


    <p>
        {% if current_user.can(Permission.FOLLOW) and user != current_user %}
        {% if not current_user.is_following(user) %}
        <a href="{{ url_for('main.follow', username=user.username) }}" class="btn btn-primary">Follow</a>
        {% else %}
        <a href="{{ url_for('main.unfollow', username=user.username) }}" class="btn btn-default">Unfollow</a>
        {% endif %}
        {% endif %}
        <a href="{{ url_for('main.followers', username=user.username) }}">Followers: <span class="badge">{{ user.followers.count() }}</span></a>
        <a href="{{ url_for('main.followed_by', username=user.username) }}">Following: <span class="badge">{{ user.followed.count() }}</span></a>
        {% if current_user.is_authenticated and user != current_user and user.is_following(current_user) %}
        | <span class="label label-default">Follows you</span>
        {% endif %}
    </p>




    {% if user == current_user %}
    <a class="btn btn-default" href='{{url_for("main.edit_profile")}}'>
        Edit Profile
    </a>
    {% endif %}

    {% if current_user.is_administrator() %}
    <a class="btn btn-danger" href='{{url_for("main.edit_profile_admin",id=user.id)}}'>
        Edit Profile[Admin]
    </a>
    {% endif %}   
</div>
{% endblock %}
